/**
 *
 * Copyright 2010 TeleNav, Inc. All rights reserved.
 * EntryController.java
 *
 */
package com.telenav.module.activitylist;

import com.telenav.framework.mvc.AbstractController;
import com.telenav.framework.mvc.AbstractModel;
import com.telenav.framework.mvc.AbstractView;
import com.telenav.framework.mvc.StateMachine;
import com.telenav.module.home.HomeController;
import com.telenav.module.map.SmartMapController;
import com.telenav.ui.AndroidUiHelper;


public class ActivityListController extends AbstractController implements IActivityListConstants
{
    private final static int[][] STATE_TABLE = new int[][]
    {
        { STATE_VIRGIN, EVENT_CONTROLLER_START, STATE_INIT, ACTION_INIT },
        { STATE_INIT, EVENT_MODEL_UPDATE_ACTIVITYLIST, STATE_INIT, ACTION_NONE },
        { STATE_INIT, CMD_GET_ACTIVITYLIST, STATE_INIT, ACTION_INIT },
        { STATE_INIT, CMD_GOTO_ACTIVITYDETAIL, STATE_ACTIVITYDETAIL, ACTION_LOAD_DETAIL},
        { STATE_ACTIVITYDETAIL, EVENT_MODEL_UPDATE_ACTIVITYDETAIL, STATE_ACTIVITYDETAIL, ACTION_NONE},
        { STATE_ACTIVITYDETAIL, CMD_GOTO_GALLERY, STATE_GALLERY, ACTION_NONE},
        { STATE_ACTIVITYDETAIL, CMD_GOTO_INVITATION, STATE_INVITATION, ACTION_NONE},
        { STATE_ANY, CMD_GOTO_MAP, STATE_GOTO_MAP, ACTION_NONE}
    };

    public ActivityListController(AbstractController superController)
    {
        super(superController);
    }
    
    protected AbstractModel createModel()
    {
        return new ActivityListModel();
    }

    protected StateMachine createStateMachine()
    {
        return new StateMachine(STATE_TABLE_COMMON, STATE_TABLE);
    }

	protected AbstractView createView()
    {
        return new ActivityListView(AndroidUiHelper.getInstance().getContext());
    }

	@Override
	protected void postStateChange(int currentState, int nextState) {
        switch (nextState)
        {
            case STATE_VIRGIN:
            {
                HomeController homeController = new HomeController(this);
                homeController.init();
                break;
            }
            case STATE_GOTO_MAP:
            {
                SmartMapController mapController = new SmartMapController(this);
                mapController.init();
            	break;
            }
        }
		
	}




}
